#!/bin/bash

set -e
set -o pipefail

git fetch --tags

SCRIPTS_DIR="$( dirname "$(readlink -f "$0")" )"

publishable_paths=$("$SCRIPTS_DIR/get-publishable-paths-from-semver-tags" | sed -E -e '/^ *$/d')
for path in $publishable_paths; do
    pushd "$path"
    echo "Attempting to publish package at path '$path'"
    "$SCRIPTS_DIR/circle-publish-npm"
    popd
done
